package main

import (
	"fmt"
	"reflect"
)

type MyInt int

func Print(v interface{}) {
	rv := reflect.ValueOf(v)
	//ele := rv.Elem()
	switch tp := rv.Kind(); tp {
	//switch tp := rv.Type(); tp {
	case reflect.Uint32:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(uint32))
		fmt.Println("Kind:", rv.Kind(), " Value:", uint32(rv.Uint()))
	case reflect.Float64:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(float64))
		fmt.Println("Kind:", rv.Kind(), " Value:", rv.Float())
	case reflect.String:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(string))
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(string))
		fmt.Println("Kind:", rv.Kind(), " Value:", rv.String())
	case reflect.Int:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(int))
		fmt.Println("Kind:", rv.Kind(), " Value:", int(rv.Int()))
	default:
		fmt.Println("Kind:", rv.Kind(), " Type:", rv.Type())
	}
	fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface())
}

func main() {
	type T struct {
		A int
		B string
	}
	t := T{23, "cqf"}
	s := reflect.ValueOf(&t).Elem()
	typeOfT := s.Type()
	for i := 0; i < s.NumField(); i++ {
		f := s.Field(i)
		fmt.Printf("%d: %s %s = %v\n", i, typeOfT.Field(i).Name, f.Type(), f.Interface())
		Print(f)
	}
}
